﻿using System.Security.Cryptography.X509Certificates;

namespace MyThirdWork
{/// <summary>
/// 随机生成字母小游戏
/// </summary>
    internal class Program
    {  //设置实验次数
        const int length = 10;
        //枚举四个字母
        enum Letters
        {
            A,
            B,
            C,
            D
        }
        static void Main(string[] args)
        {   //随机生成
            Random rnd1 = new Random();
            //耗时
            double span =0;
            //错误次数
            int error = 0;
            int i;

            for (i = 1; i <= length; i++)
            {   //开始时间               
                DateTime before = DateTime.Now;
                Console.Clear();
               
                //显示耗时，测试次数和错误次数
                Console.WriteLine($"现在耗时已为{span},现在是第{i}次随机测试，错误次数为{error}");
                //生成枚举里的随机字母
                Letters letter = (Letters)rnd1.Next(0, 4);
                //显示生成的随机字母
                Console.WriteLine(letter.ToString());
                
                bool flag = false;
                do
                {//接受用户输入
                    string input = Console.ReadLine().ToUpper();
                    //开始进行比对是否正确
                    switch (letter)
                    {
                        case Letters.A:
                            if (input == Letters.A.ToString()) flag = true;
                            else error++;
                            break;
                        case Letters.B:
                            if (input == Letters.B.ToString()) flag = true;
                            else error++;
                            break;
                        case Letters.C:
                            if (input == Letters.C.ToString()) flag = true;
                            else error++;
                            break;
                        case Letters.D:
                            if (input == Letters.D.ToString()) flag = true;
                            else error++;
                            break;
                    }
                }//不正确的话重新输入
                while (flag == false);
                //一次完成后的时间
                DateTime after = DateTime.Now;
                //耗时
                span+=(after - before).TotalSeconds;
            }


        }
    }
}
